import { request } from "@/utils/service"
import type * as Feedback from "./types/feedback"
import type * as FeedbackType from "./types/feedback-type"

// ==================== 反馈管理 ====================

/** 获取反馈列表 */
export function getFeedbackListApi(params: Feedback.FeedbackRequestData) {
  return request<Feedback.FeedbackResponseData>({
    url: "/feedback/page",
    method: "get",
    params
  })
}

/** 获取反馈详情 */
export function getFeedbackDetailApi(id: number) {
  return request<Feedback.FeedbackDetailResponseData>({
    url: `/feedback/${id}`,
    method: "get"
  })
}

/** 处理反馈 */
export function handleFeedbackApi(data: Feedback.FeedbackHandleRequestData) {
  return request({
    url: "/feedback/handle",
    method: "put",
    data
  })
}

/** 删除反馈 */
export function deleteFeedbackApi(id: number) {
  return request({
    url: `/feedback/${id}`,
    method: "delete"
  })
}

// ==================== 反馈类型管理 ====================

/** 获取反馈类型列表 */
export function getFeedbackTypeListApi(params: FeedbackType.FeedbackTypeRequestData) {
  return request<FeedbackType.FeedbackTypeResponseData>({
    url: "/feedbackType/page",
    method: "get",
    params
  })
}

/** 获取反馈类型详情 */
export function getFeedbackTypeDetailApi(id: number) {
  return request<FeedbackType.FeedbackTypeDetailResponseData>({
    url: `/feedbackType/${id}`,
    method: "get"
  })
}

/** 新增反馈类型 */
export function createFeedbackTypeApi(data: FeedbackType.FeedbackTypeFormData) {
  return request({
    url: "/feedbackType",
    method: "post",
    data
  })
}

/** 更新反馈类型 */
export function updateFeedbackTypeApi(data: FeedbackType.FeedbackTypeFormData) {
  return request({
    url: "/feedbackType",
    method: "put",
    data
  })
}

/** 删除反馈类型 */
export function deleteFeedbackTypeApi(id: number) {
  return request({
    url: `/feedbackType/${id}`,
    method: "delete"
  })
}

/** 获取所有启用的反馈类型（用于下拉选择） */
export function getEnabledFeedbackTypesApi() {
  return request<FeedbackType.EnabledFeedbackTypeResponseData>({
    url: "/feedbackType/enabled",
    method: "get"
  })
}